package com.bjpowernode.crm.web.controller;

import com.bjpowernode.crm.pojo.Clue;
import com.bjpowernode.crm.pojo.Page;
import com.bjpowernode.crm.pojo.Value;
import com.bjpowernode.crm.service.ClueService;
import com.bjpowernode.crm.utils.UUIDUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("clue")
public class ClueController {
    @Resource
    private ClueService clueService;

    @RequestMapping("listClue.json")
    public Page getAllClue(@RequestParam Map map,Page page){
        clueService.getALLClue(page,map);
        return page;
    }

    @RequestMapping("getResource.do")
    public List<Value> getAllValue(){
        return clueService.getALLValue();
    }

    @RequestMapping("showState.do")
    public List<Value> getState(){
        return clueService.getState();
    }

    @RequestMapping("addClue.do")
    public Map addClue(Clue clue){
        clue.setId(UUIDUtil.getUUID());

        clueService.addClue(clue);

        return new HashMap(){{
            put("success",true);
            put("msg","添加成功！");

        }};
    }

    @RequestMapping("listEdit.json")
    public Clue GetData(String id){
        return clueService.getData(id);
    }
}
